/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.mailbox.ACL;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import com.zimbra.cs.redolog.Version;
/*    */ import java.io.IOException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GrantAccess
/*    */   extends RedoableOp
/*    */ {
/*    */   private int mFolderId;
/*    */   private String mGrantee;
/*    */   private byte mGranteeType;
/*    */   private short mRights;
/*    */   private String mPassword;
/*    */   private long mExpiry;
/*    */   
/*    */   public GrantAccess()
/*    */   {
/* 42 */     super(MailboxOperation.GrantAccess);
/* 43 */     this.mFolderId = 0;
/* 44 */     this.mGrantee = "";
/*    */   }
/*    */   
/*    */   public GrantAccess(int mailboxId, int folderId, String grantee, byte granteeType, short rights, String password, long expiry)
/*    */   {
/* 49 */     this();
/* 50 */     setMailboxId(mailboxId);
/* 51 */     this.mFolderId = folderId;
/* 52 */     this.mGrantee = (grantee == null ? "" : grantee);
/* 53 */     this.mGranteeType = granteeType;
/* 54 */     this.mRights = rights;
/* 55 */     this.mPassword = (password == null ? "" : password);
/* 56 */     this.mExpiry = expiry;
/*    */   }
/*    */   
/*    */   protected String getPrintableData() {
/* 60 */     StringBuffer sb = new StringBuffer("id=").append(this.mFolderId);
/* 61 */     sb.append(", grantee=").append(this.mGrantee);
/* 62 */     sb.append(", type=").append(this.mGranteeType);
/* 63 */     sb.append(", rights=").append(ACL.rightsToString(this.mRights));
/* 64 */     sb.append(", args=").append(this.mPassword);
/* 65 */     sb.append(", expiry=").append(this.mExpiry);
/* 66 */     return sb.toString();
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException {
/* 70 */     out.writeInt(this.mFolderId);
/* 71 */     out.writeUTF(this.mGrantee);
/* 72 */     out.writeByte(this.mGranteeType);
/* 73 */     out.writeShort(this.mRights);
/* 74 */     out.writeBoolean(true);
/* 75 */     out.writeUTF(this.mPassword);
/* 76 */     out.writeLong(this.mExpiry);
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException {
/* 80 */     this.mFolderId = in.readInt();
/* 81 */     this.mGrantee = in.readUTF();
/* 82 */     this.mGranteeType = in.readByte();
/* 83 */     this.mRights = in.readShort();
/* 84 */     in.readBoolean();
/* 85 */     if (getVersion().atLeast(1, 2)) {
/* 86 */       this.mPassword = in.readUTF();
/*    */     }
/* 88 */     if (getVersion().atLeast(1, 36)) {
/* 89 */       this.mExpiry = in.readLong();
/*    */     }
/*    */   }
/*    */   
/*    */   public void redo() throws ServiceException {
/* 94 */     Mailbox mbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
/* 95 */     mbox.grantAccess(getOperationContext(), this.mFolderId, this.mGrantee, this.mGranteeType, this.mRights, this.mPassword, this.mExpiry);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/GrantAccess.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */